
package com.feib.stms.dao.jdbc;

import java.sql.Types;
import java.util.Date;


import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.stereotype.Repository;

import com.feib.stms.dao.ForceLogoutDao;



/**
 * @title (#)ForceLogoutHibernateDao.java<br>
 * @description <br>
 * @author Karl Chen<br>
 * @version 1.0.0 2012/06/19
 * @2012/06/19 create by Karl Chen<br>
 */
@Repository("forceLogoutDao")
public class ForceLogoutJdbcDao extends BaseJdbcDao implements ForceLogoutDao {
    /* (non-Javadoc)
     * @see com.feib.stms.dao.ForceLogoutDao#logout(java.util.Date)
     */
    public void logout(Date before) {
    	StringBuffer sql = new StringBuffer();
    	MapSqlParameterSource parameters = new MapSqlParameterSource();
		
		sql.append("update USER_LOGIN_CONTROL set IS_ACTIVED = '0' ");
		sql.append(" where IS_ACTIVED = '1' AND ACTIVITY_TIME <= :NOW_DATE ");
		parameters.addValue("NOW_DATE", before, Types.TIMESTAMP);
		
		this.getSimpleJdbcTemplate().update(sql.toString(), parameters);
    }

}
